package com.marktotop.learntwo.service.impl;


import com.marktotop.learntwo.dao.UserDao;
import com.marktotop.learntwo.entity.TbUser;
import com.marktotop.learntwo.service.UserService;

import java.util.List;

/**
 * @author WXLD
 * @data 2021/4/18 - 18:45
 */
public class UserServiceImpl implements UserService {

    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    /**
     * 添加新的用户信息
     * @param user
     * @return
     */
    @Override
    public boolean addUser(TbUser user) {
        return userDao.insertUser(user);
    }

    /**
     * 更新用户信息
     * @param user
     * @return
     */
    @Override
    public boolean updateUser(TbUser user) {
        return userDao.updateUser(user);
    }

    /**
     * 根据 id 删除用户信息
     * @param id
     * @return
     */
    @Override
    public boolean deleteUser(Integer id) {
        return userDao.deleteUser(id);
    }

    /**
     * 根据 id 查询相应的用户信息
     * @param id
     * @return
     */
    @Override
    public TbUser findById(Integer id) {
        return userDao.getOneById(id);
    }

    /**
     * 查询全部的用户信息
     * @return
     */
    @Override
    public List<TbUser> findAllUser() {
        return userDao.getAllUser();
    }
}
